<template>
  <div></div>
</template>
<script>
export default {
  methods: {
    pay() {
      const payaxios = this.$axios.create({
        timeout: 1000,
        baseURL: 'https://api.mch.weixin.qq.com/',
        header("Access-Control-Allow-Origin", "*"); // 解决请求头跨域问题
      })
      payaxios({
        method: 'post',
        url: '/v3/pay/transactions/jsapi',
        params: {
          mchid: '1900006XXX',
          out_trade_no: '1217752501201407033233368318',
          appid: 'wxdace645e0bc2cXXX',
          description: 'Image形象店-深圳腾大-QQ公仔',
          notify_url: 'https://weixin.qq.com/',
          amount: {
            total: 1,
            currency: 'CNY'
          },
          payer: {
            openid: 'o4GgauInH_RCEdvrrNGrntXDuXXX'
          }
        } // 将code传给后台，如果有其他参数需要传递，请一并传递
      }).then(res => {
        console.log(res.data)
        // 微信支付
      })
    }
  },
  mounted() {
    this.pay()
  }
}
</script>
